<?php
$today= MyDateTime::today();
$projects=ProjectTable::getActiveProjects();
?>

<table>
  <tr>
    <td>
      Display report for:
    </td>
    <td>
      <form action=index>
      <input size=2 name=month value="<?php echo $today->getMonth() ?>" >/
      <input size=5 name=year value="<?php echo $today->getYear() ?>" >
      <input type=submit value="Go">
      <input type=submit value="Today">
      </form>
    </td>
    <td>
      <?php echo link_to("Download PDF","report/pdf?month=".$today->getMonth()."&year=".$today->getYear());?>
    </td>
  </tr>
</table>

<table border=1>
  <tr valign=bottom>
    <th>Project Name</th>
    <th>Code</th>
    <th>Project Cost</th>
    <th>Category</th>
    <th>Contractor</th>
    <th>Contract Amount</th>
    <th>Total Contract Amount</th>
    <th>Computed Overhead</th>
    <th># Days to Complete</th>
    <th>Date Start</th>
    <th>Date End</th>
    <th>Release Date</th>
    <th>Releases</th>
    <th>Disbursements</th>
    <th>Post Disbursement Balance</th>
    <th>Total Release </th>
    <th>Total Disbursement </th>
    <th></th>
  </tr>
  <?php foreach($projects as $project){ ?>
  <tr>
    <td><?php echo $project["name"]?></td>
    <td><?php echo $project["code"]?></td>
    <td><?php echo $project["project_cost"]?></td>
    <td></td>
    <td></td>
    <td></td>
    <td><?php echo $project["total_bid_amount"]?></td>
    <td><?php echo $project["computed_overhead"]?></td>
    <td><?php echo $project["days_to_complete"]?></td>
    <td><?php echo $project["start_date"]?></td>
    <td><?php echo $project["end_date"]?></td>
    <td></td>
  </tr>
    <?php foreach($project->getContracts() as $contract){ ?>
  <tr>
    <td colspan=3></td>
    <td><?php echo $contract["category"]?></td>
    <td><?php echo $contract["contractor"]?></td>
    <td><?php echo $contract["bid_amount"]?></td>
    <td colspan=8></td>
    <td><?php echo $contract["bid_amount"]-$contract["total_release"]?></td>
    <td><?php echo $contract["total_release"]?></td>
    <td><?php echo $contract["total_disbursement"]?></td>
  </tr>
      <?php foreach($contract->getDisbursements() as $disbursement){ ?>
    <tr>
      <td colspan=11></td>
      <td><?php echo $disbursement["date"]?></td>
      <td><?php echo $disbursement["release_amount"]?></td>
      <td><?php echo $disbursement["disbursement_amount"]?></td>
    </tr>
      <?php } ?>
    <?php } ?>
  <?php } ?>
  <tr>
    <td></td>
  </tr>
</table>
